﻿using System;

public class DateHelper
{
    public static uint dateTime2FechaUNIX(DateTime d)
    {
        TimeSpan value = (TimeSpan)d.Subtract(new DateTime(1970, 1, 1, 0, 0, 0));

        if (value.TotalSeconds < 0) return (uint)0;
        if (value.TotalSeconds > (double)uint.MaxValue) return (uint)uint.MaxValue;

        return (uint)value.TotalSeconds;
    }

    public static DateTime FechaUNIX2DateTime(uint d)
    {
        return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(d);
    }
}
